package org.wqp.springboot.controller;

import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.bind.annotation.*;
import org.wqp.springboot.entity.Person;
import org.wqp.springboot.service.PersonService;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

@RestController
public class PersonController {
    @Autowired
    private PersonService personService;


    @RequestMapping(value = "/way/person", method = RequestMethod.GET)
    public Person findOnePerson(@RequestParam(value = "personname", required = true) String personname) {

        return personService.findByName(personname);
    }

    @RequestMapping(value = "/way/person", method = RequestMethod.PUT)
    public void modifyPerson(@RequestBody Person person) {
        personService.modifyName(person.getPersonname(), person.getId());
    }
}
